#include <iostream>
using namespace std;
int main()
{
	int a=123;
	int n,count=0;
	cin>>n;
	for(int aa=1;aa<=n;aa++)
	{
		if(aa%10==7) count++;
		if(aa%100/10==7) count++;
		if(aa%1000/100==7) count++;
		if(aa%10000/1000==7) count++;
		if(aa%100000/10000==7) count++;
	}
	cout<<count<<endl;
	return 0;
}
